<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="box">
        <h1>
            你好
            <em>张三</em>
        </h1>
    </div>

    <script>
        const boxEle = document.querySelector('#box');


        // 想要保留原有的内容，再加入新的内容
        // boxEle.innerHTML = boxEle.innerHTML + "<h1>hello world</h1>"
        boxEle.innerHTML += "<h1>hello world</h1>";

        boxEle.innerHTML = (
            `
            <div>
                <h1>hello world</h1>
                <h1>hello world</h1>
                <h1>hello world</h1>
                <h1>hello world</h1>
            </div>
            `
        )

        // boxEle.innerText = "<em>hello world</em>";
        // boxEle.innerHTML = "<h1>hello world</h1>";

        // console.log(boxEle.innerText);  // 获取当前标签内部的所有文本
        // console.log(boxEle.innerHTML);  // 获取当前标签内部的所有标签和文本
    </script>
</body>

</html>